<extend name="Public/base"/>

<block name="body">
  <div class="main-title">
    <h2>商品分类整理</h2>
  </div>

  <div class="item-field">
    <div class="tab-content">
      <form id="form" action="{:U('updatefromcategory')}?XDEBUG_SESSION_START=543253" method="post" class="form-horizontal">


          <!-- 基本信息开始 -->
          <h4 class="title"><i>1</i>商品基本信息</h4>
          <div class="form-item cf">
            <label class="item-label">商品分类</label>
            <div class="controls" id="J_itemCategory">加载中...</div>
            <input type="hidden" value="" name="category" id="J_category">
          </div>

        <div class="form-item cf">
          <label class="item-label">字键字词</label>
          <textarea  id="temp" style="width:100%;height:25px"></textarea>
          <textarea  name="content" id="content" style="width:100%;height:500px"></textarea>
        </div>

        <div class="form-item form-action cf">
          <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">保存</button>
          <a class="btn btn-return" href="{$Think.cookie.__forward__}">返 回</a>
        </div>
      </form>
    </div>
  </div>


</block>

<block name="script">
  <script src="__JS__/jquery/jquery.loadtype.js"></script>
  <script type="text/javascript" src="__JS__/jquery/jquery.printarea.js"></script>
  <script type="text/javascript">
    $(function(){
      $('#J_itemCategory').loadtype({
        type: 'itemCategory',
        store_id: "",
        name1: 'cid_1',
        name2: 'cid_2',
        name3: 'cid_3',
        value1: "{$data['cid_1']}",
        value2: "{$data['cid_2']}",
        value3: "{$data['cid_3']}",
        changed: function(c1, c2, c3){
          var c_array = [];
          c1 && c_array.push($('select[name="cid_1"] option:selected').text());
          c2 && c_array.push($('select[name="cid_2"] option:selected').text());
          c3 && c_array.push($('select[name="cid_3"] option:selected').text());
          $('#J_category').val(c_array.join('/'));
          var url = '{:U("Shop/ItemProperty/getProp?item_id=".$data["id"])}?cid_1=' + c1 + '&cid_2=' + c2 + '&cid_3=' + c3;
          var submit_checknumber = 0;
          $.get(url, function(data){
            if(data != null){
              $('#sku_prp').empty();
              $('#sku_prp').append(data);
            }else{
              $('#sku_prp').append('<div style="height:100px;line-height:100px;text-indent:20px;color:#f00;">您所选择的分类未绑定属性</div>');
            }
            submit_checknumber++;
            change_submit();
          });
          url = '{:U("Shop/ItemProperty/getProp?item_id=".$data["id"])}?type=specification&cid_1=' + c1 + '&cid_2=' + c2 + '&cid_3=' + c3;
          $.get(url, function(data){
            if(data != null){
              $('#sku_spec').empty();
              $('#sku_spec').append(data);
            }else{
              $('#sku_spec').append('<div style="height:100px;line-height:100px;text-indent:20px;color:#f00;">您所选择的分类未绑定规格</div>');
            }
            submit_checknumber++;
            change_submit();
          });
          var change_submit = function(){
            if(submit_checknumber === 2){
              $('#submit').removeAttr('disabled');
            }
          };
          // 选择品牌
          url = '{:U("Shop/Item/getBrand?brand_id=".$data["brand_id"])}?cid_1=' + c1 ;
          $.get(url,function(data){
            if(data != null){
              $('select[name="brand_id"]').empty();
              $('select[name="brand_id"]').html(data);
            }
          });

          //选择标签 author:wolfHua
          url = '{:U("Shop/ItemLabel/getLabel?item_id=".$data["id"])}?cid_1=' + c1 + '&cid_2=' + c2 ;
          $.get(url,function(data){
            if(data != null){
              $('#sku_label').empty();
              $('#sku_label').append(data);
            }
          });

        }
      });


    });


    //导航高亮
    highlight_subnav('{:U('ItemPublicCategory/index')}');

  </script>
</block>
